﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMap>
#include <QMainWindow>
#include <QSettings>
#include <QTableWidgetItem>
#include "TrManager.h"
#include "TrKlineWidget.h"
#include <spdlog/spdlog.h>

using namespace spdlog;

#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif



const QColor  TrColor_BackGround    =   QColor(21, 25, 36); //#151924
const QColor  TrColor_BackGrid      =   QColor(34, 38, 49); //#222631
const QColor  TrColor_RedKline      =   QColor(242, 54, 69);
const QColor  TrColor_GreenKline    =   QColor(8, 153, 129);
const QColor  TrColor_RedbKline     =   QColor(255, 205, 210);
const QColor  TrColor_GrebKline     =   QColor(29, 95, 94);

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow, CTrReceiver

{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    virtual ~MainWindow() override;
    virtual void OnReceiveData(TrResponseID rId, void* wParam, void* lParam) override;
    QString name(const QString& code);
    void TableUI();
    void Load_subList();
    void update_MarketData(CThostFtdcDepthMarketDataField *data);
private:
    Ui::MainWindow *ui;
    void initLogger();

    CTrManager  *m_pManager =   nullptr;
    QMap<QString, int>      m_mapSelection;
    QMap<QString, int>      m_mapVolumes;
    QSettings               *m_Configs;
    QVector<QString>        m_vecTabWidget;
    QMap<QString, QWidget*>   m_mapTrKlineWidgets;
    std::shared_ptr<spdlog::logger> m_Logger;
protected slots:
    void slot_OnTableDoubleClicked(QTableWidgetItem* item);
    void slot_OnTabClose(int index);
signals:
    void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField* pData);
    void OnQuote(char*, char*);


};
#endif // MAINWINDOW_H
